package cn.schoolwow.util.module.query.resource.flow;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import com.alibaba.fastjson.JSONArray;

import java.util.List;

public class JSONArrayToInstanceListFlow<T> implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        JSONArray jsonarray = (JSONArray) flowContext.checkData("jsonArray");
        Class<T> clazz = (Class<T>) flowContext.checkData("clazz");

        List<T> instanceList = jsonarray.toJavaList(clazz);
        flowContext.putReturnData("instanceList", instanceList);
    }

    @Override
    public String name() {
        return "JSONArray对象转换为实例列表";
    }
}
